package DBLayer;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import ModelLayer.*;

/**
 * @author Alina
 * 
 */
public class DBKundeTest {

	private DBKunde dbKundeObj;
//	public void setUp() throws Exception {
//		dbKundeObj=new DBKunde();
//	}
	@Before
	public void setUp() throws Exception {
		setDbKunde(new DBKunde());
	}

	private void setDbKunde(DBKunde dbKundeObj) {
		this.dbKundeObj = dbKundeObj;

	}

	@After
	public void tearDown() throws Exception {
	}
	@Test
	public void testDBKunde() {
		fail("Not yet implemented");
	}
	/**
	 * Test method for {@link DBLayer.DBKunde#getAllKunder(boolean)}.
	 */
	@Test
	public void testGetAllKunder() {
		dbKundeObj.getAllKunder(true);
		
	}

	/**
	 * Test method for {@link DBLayer.DBKunde#findKunde(int, boolean)}.
	 */
	@Test
	public void testFindKunde() {
		Kunde kObj = dbKundeObj.getKunde(55552222, false);
		if (kObj != null) {
			System.out.println("TelefonNr  " + kObj.getTelefonNr() + "\n "
					+ "Navn      " + kObj.getNavn() + "\n " + "e-mail    " + kObj.getEmail());
		} else {
			fail("Kunde not found");
		}
	}

	/**
	 * Test method for {@link DBLayer.DBKunde#searchKundeNavn(java.lang.String, boolean)}.
	 */
	@Test
	public void testSearchKundeNavn() {
		fail("Not yet implemented");
	}

	/**
	 * Test method for {@link DBLayer.DBKunde#insertKunde(ModelLayer.Kunde)}.
	 * @throws Exception 
	 */
	@Test
	public void testInsertKunde() throws Exception {
		
		Kunde kObject = new Kunde(55552222,"Sang", "sang@hotmail.com");
		dbKundeObj.insertKunde(kObject);
		//Normally you would delte the kunde after inserting in an insert test but because we wanted to find the kunde afterwords the delete was not implemented
	}

	/**
	 * Test method for {@link DBLayer.DBKunde#updateKunde(ModelLayer.Kunde)}.
	 */
	@Test
	public void testUpdateKunde() {
		Kunde kObject = dbKundeObj.getKunde(79797979,false);
		kObject.setEmail("alinaXP@yahoo.com");
		kObject.setNavn("Alina ");
		
		dbKundeObj.updateKunde(kObject);
	}

}
